#!/bin/sh
#
# Run a series of test cases through the driver one at a time
# using the testAfl tool.
#

AFL=${TAFL:-../TriforceAFL}
KERN=${K:-kern}

getSym() { (grep " $1\$" $KERN/kallsyms|| echo 0 0)|cut -d' ' -f1; }

CRASH=`getSym crash_kexec`
LOGSTORE=`getSym log_store`

echo "kernel $KERN"
make testAfl testRoot.cpio.gz || exit 1
./testAfl $AFL/afl-qemu-system-trace \
    -L $AFL/qemu_mode/qemu/pc-bios \
    -kernel $KERN/bzImage -initrd ./testRoot.cpio.gz \
    -m 64M -nographic -append "console=ttyS0" \
    -aflPanicAddr "$CRASH" \
    -aflDmesgAddr "$LOGSTORE" \
    -aflFile @@ -- "$@"

